//
//  UIDevice+Addition.m
//  MemoProject
//
//  Created by 晴空 on 2024/4/25.
//

#import "UIDevice+Addition.h"

@implementation UIDevice (Addition)

+ (float)safeDistanceTop {
    
    if (@available(iOS 15.0, *)) {
        
        NSSet *set = [UIApplication sharedApplication].connectedScenes;
        UIWindowScene *windowSence = [set anyObject];
        UIWindow *window = windowSence.windows.firstObject;
        return window.safeAreaInsets.top;
    }
    else {
        
        UIWindow *window = [UIApplication sharedApplication].windows.firstObject;
        return window.safeAreaInsets.top;
    }
}

+ (float)safeDistanceBottom {
    
    if (@available(iOS 15.0, *)) {
        
        NSSet *set = [UIApplication sharedApplication].connectedScenes;
        UIWindowScene *windowSence = [set anyObject];
        UIWindow *window = windowSence.windows.firstObject;
        return window.safeAreaInsets.bottom;
    }
    else {
        
        UIWindow *window = [UIApplication sharedApplication].windows.firstObject;
        return window.safeAreaInsets.bottom;
    }
}

+ (float)statusBarHeight {
    
    if (@available(iOS 15.0, *)) {
        
        NSSet *set = [UIApplication sharedApplication].connectedScenes;
        UIWindowScene *windowSence = [set anyObject];
        UIStatusBarManager *statusManager = windowSence.statusBarManager;
        return statusManager.statusBarFrame.size.height;
    }
    else {
        
        UIStatusBarManager *mgr = [UIApplication sharedApplication].windows.firstObject.windowScene.statusBarManager;
        return mgr.statusBarFrame.size.height;
    }
}

+ (float)navigationHeight {
    
    return 44.f;
}

+ (float)tabBarHeight {
    
    return 49.f;
}

+ (float)navigationFullHeight {
    
    return [UIDevice statusBarHeight] + [UIDevice navigationHeight];
}

+ (float)tabBarFullHeight {
    
    return [UIDevice tabBarHeight] + [UIDevice safeDistanceBottom];
}




@end
